package com.zifu;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.util.Arrays;

public class Tchar01 {
	public static void main(String[] args) throws Exception {
		File file = new File("E:\\PR\\a.txt");
		try (Reader reader = new FileReader(file);

		) {
			// int temp = reader.read();
			// System.out.println(temp);
			char[] cs = new char[1024];
			int len = 0;
			while ((reader.read(cs)) > -1) {
				System.out.println(len + Arrays.toString(cs));
			}
		}

		try (Reader reader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(reader);) {

			String line = null;
			int num = 1;
			while ((line = bufferedReader.readLine()) != null) {
				System.out.println(num++ + ":" + line);
			}
		}

		file = new File("E:\\PR\\a.txt");
		try (InputStream in = new FileInputStream(file);
				// Reader reader = new InputStreamReader(in);
				Reader reader = new InputStreamReader(in, "GBK");
				// Reader reader =new InputStreamReader(in,Charset.forName("GBK"));
				BufferedReader buff = new BufferedReader(reader);
		// new BufferedReader(in);
		) {

			String line = null;
			int num = 1;
			while ((line = buff.readLine()) != null) {
				System.out.println(num++ + ":" + line);
			}
		}

		// System.out.println("=------------使用注只记得自己的")；
		// String str = com.teach.FileTask01(file "GBK");
		// System.out.println(str);
		// System.out.println();

	}
}
